//
//  TitleButton.m
//  SinaWeibo
//
//  Created by Apple on 16/8/9.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "TitleButton.h"

@implementation TitleButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)layoutSubviews{
    [super layoutSubviews];
    
    [self setTitle:@"首页" forState:UIControlStateNormal];
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
    
    
//    标题和图片的x调换
    CGRect titleLabelFrame = self.titleLabel.frame;
    CGRect imageViewFrame = self.imageView.frame;
    
    [self.titleLabel setFrame:CGRectMake(imageViewFrame.origin.x, titleLabelFrame.origin.y, titleLabelFrame.size.width, titleLabelFrame.size.height)];
    [self.imageView setFrame:CGRectMake(CGRectGetMaxX(self.titleLabel.frame), imageViewFrame.origin.y, imageViewFrame.size.width, imageViewFrame.size.height)];
    
    ;

    
    
}

@end
